/******************************************************************
 * Created by: DO HOANG HAI                                       
 * Date of Creation:                                               
 * Date of last modification: 1st/Sep/2007
 *                                                                
 * Description:                                 
 * ...
 ******************************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Pbdms.Forms.Application
{
    public partial class FrmPreference : Form
    {
        //private bool changed = false;
        public FrmPreference()
        {
            InitializeComponent();
                       
            Pbdms.Common.Global.paintBackGround(this);
            loadLibSetting();
        }
                
        private void loadLibSetting()
        {
            Pbdms.AppSetting aSetting = new AppSetting();
            tbLibFolder.Text = aSetting.LibFolder;
            chkBDelete.Checked = aSetting.Lib_AskBeforeDelete;
        }

        private void btnBrowseLibFolder_Click(object sender, EventArgs e)
        {
            fbDialog.ShowDialog();
            tbLibFolder.Text = fbDialog.SelectedPath;
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            saveUpdate();            
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            saveUpdate();            
            this.Close();
        }

        void saveUpdate()
        {
            Pbdms.AppSetting aSetting = new AppSetting();
            aSetting.LibFolder = tbLibFolder.Text;
            aSetting.Lib_AskBeforeDelete = chkBDelete.Checked;
            aSetting.Save();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void chkBSaveToLib_CheckedChanged(object sender, EventArgs e)
        {
            grbSelectedFolder.Enabled = !chkBSaveToLib.Checked;
        }
    }
}